<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws.
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.).
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations).
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/modules/Account/classes/PhpFox_ComponentUserInfo.class.php, $Author:  $ */



/** Component to display user info as compact card
 *
 * Parameters:
 *  1. oAcc (manadtory) - user account object
 *
 * @package module.account
 * @version $Id: PhpFox_ComponentUserInfo.class.php 365 2008-02-25 18:02:46Z phpfoxsv $
 *
 */
class PhpFox_Mod_Account_ComponentUserInfo extends BaseComponent
{

    /** Processing method
     */
	function process()
	{
	    $oAcc = $this->getParam('oUser');
	    assert($oAcc != null);

		$oAcc->calcAge();
		$oSrvAcc = &$this->_oModule->getService('Account');
		/* @var $oSrvAcc PhpFox_Mod_Account_ServiceAccount */

		$oAcc->aData['user_online'] = $oSrvAcc->isOnline($oAcc->aData['user']);

		if ( !App::getSetting('profile_display_points') )
		{
			$iTotalPoints = $oSrvAcc->getUserPoints($oAcc);
   		    $aStars = $oSrvAcc->getStarsAsArray($iTotalPoints);
   		    $iPoints = $iTotalPoints;
   		 }
   		 
        $sWhoView = '';
        if (!App::isStaff())
        {
        	if ( $oAcc->aData['id'] != App::getUser('id') )
        	{
        		$oSrvFriend = &App::getModuleService('Account', 'Friends');
        		$sWhoView = ($oSrvFriend->checkIsFriend($oAcc->aData['user'], App::getUser('user')) ? 'AND who_view != "2"' : 'AND who_view = ""');
        	}
        }
        
        $oSrvGallery = App::getModuleService('Gallery', 'Gallery');   		 

		$this->oTpl->assign(array(
		    'aUser' => $oAcc->aData,
		));

		$this->oTpl->assignSrc(array(
			'bUseLightbox' => App::getSetting('use_lightbox'),
			'sUserPicPath'     => App::getParam('user.pic.url'),
			'sMembershipImage' => $oSrvAcc->getMembershipImage($oAcc),
			'iPoints'          => isset($iPoints) ? $iPoints : '',
		    'aStars'           => isset($aStars) ? $aStars : '',
            'bShowPoints'      => !App::getSetting('profile_display_points'),
		    'sImageUrl' => App::getParam('user.pic.url'),
		    'bImage' => file_exists(App::getParam('user.pic.path') . $oAcc->aData['user'] .".jpg") ? true : false,
		    'bViewMorePics' => $oSrvGallery->myGalleryCount($oAcc->aData['id'], $sWhoView)
		));
		$srcHtml = $this->oTpl->fetch('UserInfo.html');
		return $srcHtml;
	}

}
?>